# Author : wangyq
#

import time

user,passwd = 'wyq','wyq'

def auth(auth_type):
    print('auth_func',auth_type)
    def outer_wrapper(func):
        def wrapper(*args,**kwargs):
            print("wrapper func",*args,**kwargs)
            if auth_type == 'local':
                username = input('username : ').strip()
                password = input('password : ').strip()
                if user == username and passwd == password :
                    return func(*args,**kwargs)
                else:
                    exit('退出')
            elif auth_type == 'ldap':
                print('ldap 模式。。。。')
        return wrapper
    return outer_wrapper


def index():
    print('welecome to index!')

@auth(auth_type="local") # home = wrapper
def home():
    print('welecome to home!')
    return 'from home'
@auth(auth_type="ldap")
def bbs():
    print('welcome to bbs!')

index()
print(home()) #wrapper
bbs()